import { create } from "zustand";
import { devtools, persist, subscribeWithSelector } from "zustand/middleware";
import { immer } from "zustand/middleware/immer";

import { createUserSlice } from "./user-slice";
import { createCountSlice } from "./count-slice";
import { createTodoSlice } from "./todo-slice";


export const useStore = create()(
  devtools(
    persist(
      subscribeWithSelector(
        immer((...a) => ({
          ...createUserSlice(...a),
          ...createCountSlice(...a),
         ...createTodoSlice(...a),
        }))
      ),
      {
        name: "local-storage",
      }
    )
  )
);
